package com.huabo.monitor.oracle.mapper;


import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.hbfk.util.PageInfo;
import com.huabo.monitor.oracle.entity.TblAssesselement;
import com.huabo.monitor.oracle.entity.TblAssesstemple;

public class TblAssesstempleMapperSqlConfig {
    public String findByPageInfo (PageInfo<TblAssesstemple> pageInfo){
        TblAssesstemple tblAssesstemple = pageInfo.getCondition();
        StringBuffer sbSql = new StringBuffer("SELECT * FROM (SELECT T1.*,ROWNUM RN  FROM (SELECT * FROM TBL_ASSESSELEMENT WHERE 1 = 1");
        if (null != tblAssesstemple.getTempleNumber() ){
            //    wrapper.eq(TblAssesstemple::getTempleNumber, tblAssesstemple.getTempleNumber());
            sbSql.append(" AND TEMPLENUMBER = " + tblAssesstemple.getTempleNumber());
        }
        if (null != tblAssesstemple.getTemplename()){
            //    wrapper.eq(TblAssesstemple::getTemplename, tblAssesstemple.getTemplename());
            sbSql.append(" AND TEMPLENAME = " + tblAssesstemple.getTemplename());
        }

        sbSql.append(") T1 WHERE ROWNUM <= "+(pageInfo.getCurrentRecord()+pageInfo.getPageSize())+" ) T2 WHERE T2.RN > "+pageInfo.getCurrentRecord());

        return sbSql.toString();
    }

    public String findByCount (PageInfo<TblAssesstemple> pageInfo){
        TblAssesstemple tblAssesstemple = pageInfo.getCondition();
        StringBuffer sbSql = new StringBuffer("select count(*) from (SELECT * FROM TBL_ASSESSELEMENT WHERE 1 = 1");
        if (null != tblAssesstemple.getTempleNumber() ){
            //    wrapper.eq(TblAssesstemple::getTempleNumber, tblAssesstemple.getTempleNumber());
            sbSql.append(" AND TEMPLENUMBER = " + tblAssesstemple.getTempleNumber());
        }
        if (null != tblAssesstemple.getTemplename()){
            //    wrapper.eq(TblAssesstemple::getTemplename, tblAssesstemple.getTemplename());
            sbSql.append(" AND TEMPLENAME = " + tblAssesstemple.getTemplename());
        }

        return sbSql.toString();
    }


}
